Intermediate Code Generation
Q11.
Consider the intermediate code given below. (1) i = 1 (2) j = 1 (3) t1 = 5 * i (4) t2 = t1 + j (5) t3 = 4 * t2 (6) t4 = t3 (7) a[t4] = -1 (8) j = j + 1 (9) if j\leq 5 goto (3) (10) i=i+1 (11) if i\lt 5 goto (2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, areQ12.
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?Q13.
A variable x is said to be live at a statement S_{i} in a program if the following three conditions hold simultaneously: i. There exists a statement S_{j} that uses x ii. There is a path from S_{i} to S_{j} in the flow graph corresponding to the program iii. The path has no intervening assignment to x including at S_{i} and S_{j} The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph areQ15.
Consider the basic block given below. a= b + c c =a + d d =b + c e =d - b a =e + b The minimum number of nodes and edges present in the DAG representation of the above basic block respectively areQ16.
The minimum number of arithmetic operations required to evaluate the polynomial P(x)=x^{5}+4x^{3}+6x+5 for a given value of x, using only one temporary variable is _____.Q18.
For a C program accessing x[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits. t0 = i * 1024 t1 = j * 32 t2 = k * 4 t3 = t1 + t0 t4 = t3 + t2 t5 = x[t4] Which one of the following statements about the source code for the C program is CORRECT?Q19.
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment. c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; } Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code?